package com.moonshineproject.commands
{
	import com.moonshineproject.GlobalEventDispatcher;
	import com.moonshineproject.IDEModel;
	import com.moonshineproject.editor.BasicTextEditor;
	import com.moonshineproject.plugin.events.EditorPluginEvent;
	
	import flash.events.Event;
	
	public class NewFileCommand implements ICommand
	{
		public function execute(event:Event):void {
						
			var model:IDEModel = IDEModel.getInstance();
			var editor:BasicTextEditor = new BasicTextEditor();
			
			// Let plugins hook in syntax highlighters & other functionality
			var editorEvent:EditorPluginEvent = new EditorPluginEvent(EditorPluginEvent.EVENT_EDITOR_OPEN);
			editorEvent.editor = editor.getEditorComponent();
			GlobalEventDispatcher.getInstance().dispatchEvent(editorEvent);
			
			model.editors.addItem( editor );
		}

	}
}